# Stage 1: compile from source and generate jar package
FROM docker.io/library/maven:3.8.6-eclipse-temurin-17-alpine AS build
COPY ./.m2 /root/.m2/
COPY ./src-demo /build/
WORKDIR /build
RUN mvn -s /root/.m2/settings.xml \
        -Dmaven.repo.local=/root/.m2/repository \
        clean package -DskipTests

# Stage 2: Create final docker image
FROM docker.io/library/eclipse-temurin:17.0.5_8-jre-alpine
COPY --from=build /build/target/*.jar /build/src/main/resources/application.yml /app/
EXPOSE 8080
WORKDIR /app
ENTRYPOINT ["java", "-jar","ruoyi-admin.jar"]
